import { ref } from "vue";
import { FormInstance } from "element-plus";

export const useData = () => {
  const ruleFormRef = ref<FormInstance>();
  const formData = ref({
    id: undefined,
    remark: undefined,
    orderCode: undefined,
    gmtCreate: undefined,
    gmtModified: undefined,
    createBy: undefined,
    createByName: undefined,
    modifiedBy: undefined,
    modifiedByName: undefined,
    type: undefined,
    code: undefined,
    deviceId: undefined,
    deviceHwVersion: undefined,
    deviceSwVersion: undefined,
    name: undefined,
    picture: undefined,
    description: undefined,
    lockState: undefined,
    state: undefined,
    hdop: undefined,
    latitude: undefined,
    longitude: undefined,
    onlineTime: undefined,
    offlineTime: undefined,
    gpsCollectTime: undefined,
    nonStandard: undefined,
    nonStandardContent: undefined,
    nonStandardCycle: undefined,
    productionTime: undefined,
    upgrading: undefined,
    forkSpacing: undefined,
    forkLength: undefined,
    forkWidth: undefined,
    forkThickness: undefined,
    productCategoryId: undefined,
    productCategoryName: undefined,
    projectId: undefined,
    projectName: undefined,
    projectCode: undefined,
    gateFrameInclinationAngle: 0,
    aeArEmptyFrontWheelLoad: undefined,
    aeArEmptyRearWheelLoad: undefined,
    aeArFullFrontWheelLoad: undefined,
    aeArFullRearWheelLoad: undefined,
    isRegister: true,
    performanceParameterTable: undefined,
    productDataList: [],
    assemblyInfos: [],
    productParts: []
  });
  const rules: any = ref({
    type: [{ required: true, message: "请选择产品类型" }],
    productCategoryId: [{ required: true, message: "请选择产品型号" }],
    projectId: [{ required: true, message: "请选择所属订单" }],
    productionTime: [{ required: true, message: "请选择车出厂时间" }],
    code: [{ required: true, message: "请输入车架号" }]
  });
  // const rules = reactive({
  //   avatarUrl: [{ required: true, message: "请上传用户头像" }],
  //   mobile: [{ required: true, pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/, message: "请填写手机号" }],
  //   totalIntegral: [{ required: false, pattern: /^[0-9]+$/, message: "只能为数字" }],
  //   iceIntegral: [{ required: false, pattern: /^[0-9]+$/, message: "只能为数字" }],
  //   status: [{ required: false, message: "请选择状态" }],
  //   productionTime: [{ required: true, message: "请选择车出厂时间" }]
  // });
  const selectList: any = ref({});
  const appearance: any = ref([]);
  const testVideo: any = ref([]);
  return {
    formData,
    ruleFormRef,
    rules,
    selectList,
    appearance,
    testVideo
  };
};
